import React ,{ Component } from 'react';
import { Redirect } from 'react-router-dom';
import {observer, inject} from 'mobx-react';

export default (WrappedComponent)=>{

    @inject('userstore')
    @observer 
    class Authenticate extends Component {

        render(){
            console.log(this.props.userstore)
            if(!this.props.userstore.authorized) {
              return (
                <Redirect to="/"/>
               )
            }
            return <WrappedComponent {...this.props}/>
        }
    }

    return Authenticate;
}